package com.dzu.easy;

/**
 * @author ZhaoDong
 * @date 2022/12/9 10:46
 * @description 507. 完美数
 */
public class Test507 {
    public static void main(String[] args) {

        System.out.println(checkPerfectNumber(29));
    }

    public static boolean checkPerfectNumber(int num) {
        if (num == 1) {
            return false;
        }
        int res = 1;
        for (int i = 2; i < num / i; i++) {

            if (num % i == 0) {
                res += i;
                if (i * i != num) {
                    res += num / i;
                }
            }
        }
        return res == num;

    }
}
